package com.qs.eggs.view.activity;


import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

import com.Zxing.Demo.CaptureActivity;
import com.google.gson.Gson;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.callback.StringCallback;
import com.qs.eggs.Constants;
import com.qs.eggs.R;

import java.util.HashMap;

import okhttp3.Call;
import okhttp3.Response;

public class SubmitLoginActivity extends Activity implements View.OnClickListener{
    private Button submit,cancel;
    private String accountname,password;
    private String uuid;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_submit_login);
        accountname=getIntent().getStringExtra("accountname");
        password=getIntent().getStringExtra("password");
        uuid=getIntent().getStringExtra("uuid");
        initView();
    }
    private void initView(){
        submit=(Button)findViewById(R.id.submit);
        cancel=(Button)findViewById(R.id.cancel);

        submit.setOnClickListener(this);
        cancel.setOnClickListener(this);
    }
    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.submit:
                HashMap<String,String> map=new HashMap<String, String>();
                map.put("accountname",accountname);
                map.put("password",password);
                map.put("uuid",uuid);
                Gson gson=new Gson();
                String params=gson.toJson(map);
                OkGo.post(Constants.URL_BASE+"mallLogin?action=confirmLogin")
                        .params("params",params)
                        .execute(new StringCallback() {
                            @Override
                            public void onSuccess(String s, Call call, Response response) {
                                System.out.print("信息=="+s);
                                if (s.equals("\"true\"")){
                                   SubmitLoginActivity.this.finish();
                                }else{

                                }
                            }
                        });
                break;
            case R.id.cancel:
                SubmitLoginActivity.this.finish();
                break;
        }
    }
}
